home *** CD-ROM | disk | FTP | other *** search
/ Imagine the Universe (9th Edition) / Imagine the Universe 9 - Disc 1.iso / pc / imagine / docs / science / try_l2 / javascript / supernovae.js < prev   
Encoding:
Text File  |  2002-01-09  |  1.1 KB  |  49 lines

  1. size1 = "Blank";
  2. size2 = "Blank";
  3. size3 = "Blank";
  4. size4 = "Blank";
  5.  
  6. function checkme() {
  7. size1 = document.supernovae.answer1.value - 0;
  8. if (!size1) {size1 = "Blank";}
  9. size2 = document.supernovae.answer2.value - 0;
  10. if (!size2) {size2 = "Blank";}
  11. size3 = document.supernovae.answer3.value - 0;
  12. if (!size3) {size3 = "Blank";}
  13. size4 = document.supernovae.answer4.value - 0;
  14. if (!size4) {size4 = "Blank";}
  15.     
  16.     
  17.     RightAnswer1 = 100;
  18.     RightAnswer2 = 1000;
  19.     RightAnswer3 = 10000;
  20.     RightAnswer4 = 4000;
  21.     
  22.     NumberCorrect = 0;
  23.     Extra = 0;
  24.     AnswerPage = 'supernovae_solution.html';
  25.     
  26.     if (size1 == RightAnswer1) {
  27.         NumberCorrect++;
  28.     }
  29.     if (size2 == RightAnswer2) {
  30.         NumberCorrect++;
  31.     }
  32.     if (size3 == RightAnswer3) {
  33.         NumberCorrect++;
  34.     }
  35.     if (size4 == RightAnswer4) {
  36.         Extra++;
  37.     }
  38.     
  39.     if (Extra == 1) {
  40.     alert ("You answere " +NumberCorrect + " out of 3 questions correctly and got the bonus question!");
  41.     }
  42.     else {
  43.         alert ("You answered " +NumberCorrect + " out of 3 questions correctly!");
  44.     }
  45.     location = AnswerPage; 
  46. }
  47.  
  48.     
  49.